<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>学习vue</title>
    <script src="../js/vue.js"></script>
    <style>
        *{
            margin: 1px;
        }
    </style>
</head>
<body>
    <div id="root">
    </div>
    <script type="text/javascript">
        Vue.config.productionTip = false;
        //创建school组件
        const hello = {
            template:`
                <div>    
                    <h1>hello</h1>
                </div>
            `,
        }
        //创建student组件
        const student = {
            template:`
                <div>    
                    <h1>学生{{name}}{{age}}</h1>
                </div>
            `,
            data(){
                return {
                    name:'zzz1',
                    age:18
                }
            },
        }
        //创建school组件
        const school = {
            template:`
                <div>    
                    <h1>学校{{name}}{{address}}</h1>
                    <student></student>
                </div>
            `,
            data(){
                return {
                    name:'zzz1',
                    address:"zzzzzzzzfffffff"
                }
            },
            // 注册成子组件
            components:{
                student
            }
        }
        // 创建app组件
        // 一般用app管理所有组件，root下面就只有1个app组件。
        const app = {
            template:`
                <div>    
                    <hello></hello>
                    <school></school>
                </div>
            `,
            // 注册成子组件
            components:{
                hello,
                school
            }
        }
        new Vue({
            el:'#root',
            template:"<app></app>",
            components:{
                app
            },
        })
    </script>    
</body>
</html>